package com.liuqi.loggers.core;

import java.util.Arrays;

/**
 * 日志输出事件
 *
 * @author liuqi
 * @date 2024/10/14 15:48
 **/
public class LoggerEvent {

    /**
     * 日志级别
     */
    private Level level;

    /**
     * 日志消息
     */
    private String message;

    /**
     * 日志消息格式化参数
     */
    private Object[] arguments;

    /**
     * 异常
     */
    private Throwable throwable;

    /**
     * 目标类
     */
    private String name;

    /**
     * 记录日志时间戳
     */
    private long timestamp;

    /**
     * 当前输出日志线程
     */
    private Thread thread;

    public LoggerEvent(Level level, String message, Object[] arguments, Throwable throwable, String name) {
        this.level = level;
        this.message = message;
        this.arguments = arguments;
        this.throwable = throwable;
        this.name = name;
        this.timestamp = System.currentTimeMillis();
        this.thread = Thread.currentThread();
    }

    public Level getLevel() {
        return level;
    }

    public String getMessage() {
        return message;
    }

    public Object[] getArguments() {
        return arguments;
    }

    public Throwable getThrowable() {
        return throwable;
    }

    public String getName() {
        return name;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public Thread getThread() {
        return thread;
    }

    @Override
    public String toString() {
        return "LoggerEvent{" +
                "level=" + level +
                ", message='" + message + '\'' +
                ", arguments=" + Arrays.toString(arguments) +
                ", throwable=" + throwable +
                ", name='" + name + '\'' +
                ", timestamp=" + timestamp +
                ", thread=" + thread +
                '}';
    }

}
